package com.xmall.controller.wx;

import com.xmall.bean.table.Topic;
import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.vo.WxTopicDetailVo;
import com.xmall.bean.vo.WxTopicListVo;
import com.xmall.service.WxTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("wx/topic")
public class WxTopicController {

    @Autowired
    WxTopicService wxTopicService;

    @GetMapping("detail")
    public BaseRespVo wxTopicDetail(Integer id){
        //新建返回WxTopicDetailVo
        WxTopicDetailVo wxTopicDetailVo = wxTopicService.wxTopicDetail(id);
        return BaseRespVo.ok(wxTopicDetailVo);
    }

    @GetMapping("list")
    public BaseRespVo wxTopicList(Integer page, Integer size){
        //新建WxTopicListVo
        WxTopicListVo wxTopicListVo = wxTopicService.wxTopicList(page, size);
        return BaseRespVo.ok(wxTopicListVo);
    }

    @GetMapping("related")
    public BaseRespVo wxTopicRelated(Integer id){
        //返回值未list<Topic>的数组
        List<Topic> topics = wxTopicService.wxTopicRelated(id);
        return BaseRespVo.ok(topics);
    }
}
